import "crvpuppet"

define at3_cvmfs($webaddr="", $roleid="") {

#  $squidproxy=""
  
  if $AutoMode==true and $CloudCRV==true {
    $squidproxy=get_provider_attr($webaddr,$roleid,"SquidProxy")    
  }
  
  if ( $AutoMode == false ) or ( $AutoMode==true and $CloudCRV==true ) {

    file { "/etc/cvmfs/default.local":
      owner => "root",
      group => "root",
      mode => 644,
      content => template("at3_cvmfs/default.local.tpl"),
      notify => Service["cvmfs"],
    }
    
    package { ["cvmfs","fuse","cvmfs-init-scripts","cvmfs-auto-setup"]:
      ensure => installed,
    }
    
    service { [ "cvmfs"]:
      hasstatus => true,
      hasrestart => true,
      ensure => running,
      enable => true,
      require => Package["cvmfs"],
    }
    
    exec {"/sbin/service cvmfs restartautofs":
      require => Service["cvmfs"],
    }

    
  }
  
  if $AutoMode==true and $CloudCRV==true {
    #publish some variables, e.g. InteractiveNodePublicAddress and let CloudCRV display it on the front.
    #set_role_attr($webaddr,$roleid,"ProfileApplied","True")
  }
}

define at3_cvmfs_reverse($webaddr, $roleid) {
  set_role_attr($webaddr,$roleid,"ReverseProfileApplied","True")
}

